<template>
	<view>
		<!-- 上面的图案部分开始 -->
		<view style="margin-top: 200upx;" class="flex flex-direction align-center">
			<image class="logo" src="../../static/logo.png"></image>
			<view style="margin-top: 30upx; color: grey;">岭北食堂，健康好吃都有保障</view>
		</view>
		<!-- 上面的图案部分结束 -->
		<!-- 下面信息输入部分开始 -->
		<view style="margin-top: 40upx;">
			<view class="input-fa">
			<view><input class="log-input" placeholder="学号" v-model="form.xuehao" type="text"/></view>
			</view>
			<view  class="input-fa">
			<view><input class="log-input" placeholder="密码" v-model="form.password" :password="true"/></view>
		</view>
		</view>
		<!-- 下面信息输入部分结束 -->
		<!-- 登录按钮开始 -->
		<view style="margin-top: 40upx;" class="flex justify-center">
			<button @tap="login" class="bg-gradual-red round" style="width: 650upx;">登录</button>
		</view>
		<!-- 登录按钮结束 -->
		<!-- 忘记密码开始 -->
		<view class="input-fa" style="margin-top: 30upx;">
			<text>忘记密码?</text>
		</view>
		<!-- 忘记密码结束 -->
	</view>
</template>

<script>
	export default{
		data(){
			return{
				form:{
					xuehao: "",
					password: ""
				}
			}
		},
		methods:{
			login(){

				uni.request({
					url:this.$url+"/user/login",
					data:{
						xuehao:this.form.xuehao,
						password:this.form.password
					},
					method:"POST",

					success: (res) => {
						uni.showToast({
							icon:"none",
							title:res.data.desc+(res.data.status==0? (res.data.info.name):'')
						})
						// 测试代码
						// console.log(res.data)

						if(res.data.status==0){
                            uni.setStorageSync("uid",res.data.uid);
                            uni.switchTab({
                            	url:"../my/my"
                            })
						}
					

					}
				})
			}
			
		}
		
	}
</script>

<style>
	.logo{
		height: 200upx;
		width: 200upx;
	}
	.log-input{
		height: 100upx;
		border-bottom: 1upx solid #DDDDDD;
	}
	.input-fa{
		padding-left: 40upx;
		padding-right: 40upx;
	}
</style>
